package com.qiantu.phone.ui.dialog;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.qiantu.phone.R;
import com.lxj.xpopup.core.AttachPopupView;

public class SelectDecideTypeDialog extends AttachPopupView {

    private DialogClickListener mDialogClickListener;
    private TextView tvMeetAll;
    private TextView tvMeetOne;
    public SelectDecideTypeDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.dialog_select_decide_type;
    }

    // 执行初始化操作，比如：findView，设置点击，或者任何你弹窗内的业务逻辑
    @Override
    protected void onCreate() {
        super.onCreate();
        tvMeetAll = findViewById(R.id.tv_meet_all);
        tvMeetOne = findViewById(R.id.tv_meet_one);
        tvMeetAll.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if(mDialogClickListener != null){
                    //条件类型 1：满足所有条件、2.只满足一个
                    mDialogClickListener.onSelected(1);
                }
            }
        });
        tvMeetOne.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                if(mDialogClickListener != null){
                    //条件类型 1：满足所有条件、2.只满足一个
                    mDialogClickListener.onSelected(2);
                }
            }
        });
    }

    // 设置最大宽度，看需要而定
    @Override
    protected int getMaxWidth() {
        return super.getMaxWidth();
    }

    // 设置最大高度，看需要而定
    @Override
    protected int getMaxHeight() {
        return super.getMaxHeight();
    }

    /**
     * 弹窗的宽度，用来动态设定当前弹窗的宽度，受getMaxWidth()限制
     *
     * @return
     */
    protected int getPopupWidth() {
        return 0;
    }

    /**
     * 弹窗的高度，用来动态设定当前弹窗的高度，受getMaxHeight()限制
     *
     * @return
     */
    protected int getPopupHeight() {
        return 0;
    }

    @Override
    protected void doAfterShow() {
        super.doAfterShow();
    }

    @Override
    protected void beforeDismiss() {
        super.doAfterDismiss();
    }

    public void setDialogClickListener(@Nullable DialogClickListener listener) {
        mDialogClickListener = listener;
    }

    public interface DialogClickListener {
        void onSelected(int decideType);
    }

//    @Override
//    protected PopupAnimator getPopupAnimator() {
//        PopupAnimator animator;
//        if (isShowUpToTarget()) {
//            // 在上方展示
//            animator = new ScrollScaleAnimator(getPopupContentView(), getAnimationDuration(), PopupAnimation.ScrollAlphaFromBottom);
//        } else {
//            // 在下方展示
//            animator = new ScrollScaleAnimator(getPopupContentView(), getAnimationDuration(), PopupAnimation.ScrollAlphaFromTop);
//        }
//        return animator;
//    }
}
